/**
 * Game Manager
 */
var GAME_STATS = "GameStats";
var GAME_STATS_VERSION = "0.1";
var theGameStats = null;

function GameStats() {
}

function storeGameStats(gs) {
	var data = { version: GAME_STATS_VERSION };
	LocalStorage.set(GAME_STATS, JSON.stringify(data));
}
function loadGameStats() {
	var gs = new GameStats();

	var data = JSON.parse(LocalStorage.get(GAME_MANAGER));
	if (data.version != GAME_STATS_VERSION) {
		LocalStorage.del(GAME_STATS);
		throw "GameStats is wrong version!";
	}

	return gs;
}

function getGameStats() {
	if (!theGameStats) {
		if (LocalStorage.has(GAME_STATS)) {
			theGameStats = loadGameStats();
		} else {
			theGameStats = new GameStats();
//			storeGameManager(theGameStats);
		}
	}
	return theGameStats;
}
